package com.android.job.service.request;

import java.util.ArrayList;

import org.apache.http.message.BasicNameValuePair;

import android.os.Handler;
import android.util.Log;

import com.android.job.fusion.FusionCode;
import com.android.job.service.ConnectionTask;
import com.android.job.service.JSONRequest;
import com.android.job.util.CommonUtil;
import com.android.job.util.json.JSONException;
import com.android.job.util.json.JSONObject;

public class SendResumeRequest extends JSONRequest
{

	private String personnelId;
	private String companyId;
	private String postId;

	public SendResumeRequest(Handler handler, String httpUrl)
	{
		super(handler, httpUrl);
		setHttpType(ConnectionTask.POST);
	}

	public void setValues(String personnelId, String companyId ,String postId)
	{
		this.personnelId = personnelId;
		this.companyId = companyId;
		this.postId = postId;
	}

	@Override
	protected boolean parseJSONResponse(JSONObject json)
	{
		Log.i("SendResumeRequest", "====response======json======"+json.toString());
		if (!json.isNull("jsonData"))
		{
			JSONObject jsonObject;
			try
			{
				jsonObject = json.getJSONObject("jsonData");
				if (!jsonObject.isNull("success"))
				{
					String success = jsonObject.getString("success");
					CommonUtil.sendMessage(handler, FusionCode.RETURN_JSONOBJECT,
							success);
				}
			}
			catch (JSONException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		
		}

		return true;
	}

	@Override
	protected void appendMainBody()
	{
		this.paramsters = new ArrayList();
			JSONObject userJson;
			try
			{
				jsonObject = new JSONObject();
				userJson = new JSONObject();

				userJson.put("personnelId", personnelId);
				userJson.put("companyId", companyId);
				userJson.put("postId", postId);

				jsonObject.put("requestType", "sendResume");
				jsonObject.put("jsonData", userJson);
				paramsters.add(new BasicNameValuePair("jsonData", jsonObject.toString()));
				Log.i("SendResumeRequest","===request===json======"+jsonObject.toString());
			} catch (JSONException e)
			{
				e.printStackTrace();
			}
		
	}
}
